import { SUPER_EXPR } from '@angular/compiler/src/output/output_ast';
import { Component, Injectable, InjectionToken, Injector, OnInit } from '@angular/core';
enum Genter {
  male = 'male',
  female = 'female'
}



// tslint:disable
//@Injectable()
class User {
  constructor(private name: number,private age: number) {

  }
}
@Injectable({
  providedIn: 'root'
}
)
class Admin {
  private sex: Genter = Genter.female;
  constructor(private user: User) {

  }
}
const baseUrlToken =new InjectionToken('baseUrl');
@Component({
  selector: 'app-home-grand',
  templateUrl: './home-grand.component.html',
  styleUrls: ['./home-grand.component.scss']
})
export class HomeGrandComponent implements OnInit {
  
  constructor() { }

  ngOnInit() {
    const injector = Injector.create({
      providers: [
        {
          provide: User,
          useFactory: ()=>{
            return new User(11,11)
          },
          deps:[]
        },{ 
          provide:Admin,
          useClass: Admin,
          deps:[User]
        },{
          provide: baseUrlToken,
          useValue: 'https://lcoalhost.com'
        }
      ]
    })
    //const p = new P("dsfas")
    console.log(injector.get(User))
    console.log(injector.get(baseUrlToken))
  }

}
